package com.google.android.material.navigation;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.ClassLoaderCreator;
import android.os.Parcelable.Creator;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import androidx.annotation.DimenRes;
import androidx.annotation.Dimension;
import androidx.annotation.DrawableRes;
import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.StyleRes;
import androidx.core.view.ViewCompat;
import androidx.customview.view.AbsSavedState;
import com.google.android.material.internal.ScrimInsetsFrameLayout;
import o.aqu.d;
import o.aqu.f;
import o.aqu.n;
import o.ar;
import o.arv;
import o.asa;
import o.asc;
import o.az;
import o.bd;
import o.bd.e;
import o.bj;
import o.cw;
import o.fo;
import o.ij;

public class NavigationView extends ScrimInsetsFrameLayout {
    private static final int[] ˊ = new int[]{16842912};
    private static final int[] ˏ = new int[]{-16842910};
    private final int ʼ;
    private MenuInflater ʽ;
    c ˎ;
    private final asc ॱॱ;
    private final arv ᐝ;

    public static class SavedState extends AbsSavedState {
        public static final Creator<SavedState> CREATOR = new ClassLoaderCreator<SavedState>() {
            public /* synthetic */ Object createFromParcel(Parcel parcel) {
                return ˏ(parcel);
            }

            public /* synthetic */ Object createFromParcel(Parcel parcel, ClassLoader classLoader) {
                return ˏ(parcel, classLoader);
            }

            public /* synthetic */ Object[] newArray(int i) {
                return ˊ(i);
            }

            public SavedState ˏ(Parcel parcel, ClassLoader classLoader) {
                return new SavedState(parcel, classLoader);
            }

            public SavedState ˏ(Parcel parcel) {
                return new SavedState(parcel, null);
            }

            public SavedState[] ˊ(int i) {
                return new SavedState[i];
            }
        };
        public Bundle ॱ;

        public SavedState(Parcel parcel, ClassLoader classLoader) {
            super(parcel, classLoader);
            this.ॱ = parcel.readBundle(classLoader);
        }

        public SavedState(Parcelable parcelable) {
            super(parcelable);
        }

        public void writeToParcel(@NonNull Parcel parcel, int i) {
            super.writeToParcel(parcel, i);
            parcel.writeBundle(this.ॱ);
        }
    }

    public interface c {
        boolean ˏ(@NonNull MenuItem menuItem);
    }

    public NavigationView(Context context) {
        this(context, null);
    }

    public NavigationView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, d.ˋॱ);
    }

    public NavigationView(Context context, AttributeSet attributeSet, int i) {
        ColorStateList ॱ;
        int ॱॱ;
        super(context, attributeSet, i);
        this.ॱॱ = new asc();
        this.ᐝ = new arv(context);
        cw ˏ = asa.ˏ(context, attributeSet, n.ˊꜟ, i, f.ॱॱ, new int[0]);
        ViewCompat.ˏ(this, ˏ.ˋ(n.ˊᐨ));
        if (ˏ.ᐝ(n.ˋʾ)) {
            ViewCompat.ˋ(this, (float) ˏ.ˎ(n.ˋʾ, 0));
        }
        ViewCompat.ˎ(this, ˏ.ˋ(n.ˊꜞ, false));
        this.ʼ = ˏ.ˎ(n.ˊꞌ, 0);
        if (ˏ.ᐝ(n.ˋʿ)) {
            ॱ = ˏ.ॱ(n.ˋʿ);
        } else {
            ॱ = ˊ(16842808);
        }
        if (ˏ.ᐝ(n.ˋᐨ)) {
            ॱॱ = ˏ.ॱॱ(n.ˋᐨ, 0);
            int i2 = 1;
        } else {
            ॱॱ = 0;
            boolean z = false;
        }
        ColorStateList colorStateList = null;
        if (ˏ.ᐝ(n.ˊﾞ)) {
            colorStateList = ˏ.ॱ(n.ˊﾞ);
        }
        if (i2 == 0 && r3 == null) {
            colorStateList = ˊ(16842806);
        }
        Drawable ˋ = ˏ.ˋ(n.ˋˈ);
        if (ˏ.ᐝ(n.ˋˉ)) {
            this.ॱॱ.ˋ(ˏ.ˎ(n.ˋˉ, 0));
        }
        int ˎ = ˏ.ˎ(n.ˋᐧ, 0);
        this.ᐝ.ॱ(new e(this) {
            final /* synthetic */ NavigationView ॱ;

            {
                this.ॱ = r1;
            }

            public boolean ॱ(bd bdVar, MenuItem menuItem) {
                return this.ॱ.ˎ != null && this.ॱ.ˎ.ˏ(menuItem);
            }

            public void ˎ(bd bdVar) {
            }
        });
        this.ॱॱ.ॱ(1);
        this.ॱॱ.ˏ(context, this.ᐝ);
        this.ॱॱ.ˎ(ॱ);
        if (i2 != 0) {
            this.ॱॱ.ˎ(ॱॱ);
        }
        this.ॱॱ.ˊ(colorStateList);
        this.ॱॱ.ॱ(ˋ);
        this.ॱॱ.ˊ(ˎ);
        this.ᐝ.ˊ(this.ॱॱ);
        addView((View) this.ॱॱ.ˋ((ViewGroup) this));
        if (ˏ.ᐝ(n.ˊﾟ)) {
            ˎ(ˏ.ॱॱ(n.ˊﾟ, 0));
        }
        if (ˏ.ᐝ(n.ˋˑ)) {
            ˏ(ˏ.ॱॱ(n.ˋˑ, 0));
        }
        ˏ.ॱ();
    }

    protected Parcelable onSaveInstanceState() {
        Parcelable savedState = new SavedState(super.onSaveInstanceState());
        savedState.ॱ = new Bundle();
        this.ᐝ.ˏ(savedState.ॱ);
        return savedState;
    }

    protected void onRestoreInstanceState(Parcelable parcelable) {
        if (parcelable instanceof SavedState) {
            SavedState savedState = (SavedState) parcelable;
            super.onRestoreInstanceState(savedState.ˊ());
            this.ᐝ.ˋ(savedState.ॱ);
            return;
        }
        super.onRestoreInstanceState(parcelable);
    }

    public void setNavigationItemSelectedListener(@Nullable c cVar) {
        this.ˎ = cVar;
    }

    protected void onMeasure(int i, int i2) {
        switch (MeasureSpec.getMode(i)) {
            case Integer.MIN_VALUE:
                i = MeasureSpec.makeMeasureSpec(Math.min(MeasureSpec.getSize(i), this.ʼ), 1073741824);
                break;
            case 0:
                i = MeasureSpec.makeMeasureSpec(this.ʼ, 1073741824);
                break;
        }
        super.onMeasure(i, i2);
    }

    @RestrictTo({RestrictTo.d.LIBRARY_GROUP})
    public void ˋ(ij ijVar) {
        this.ॱॱ.ॱ(ijVar);
    }

    public void ˎ(int i) {
        this.ॱॱ.ˏ(true);
        ˎ().inflate(i, this.ᐝ);
        this.ॱॱ.ˏ(false);
        this.ॱॱ.ˊ(false);
    }

    public View ˏ(@LayoutRes int i) {
        return this.ॱॱ.ˏ(i);
    }

    public void setItemIconTintList(@Nullable ColorStateList colorStateList) {
        this.ॱॱ.ˎ(colorStateList);
    }

    public void setItemTextColor(@Nullable ColorStateList colorStateList) {
        this.ॱॱ.ˊ(colorStateList);
    }

    public void setItemBackgroundResource(@DrawableRes int i) {
        setItemBackground(fo.ˊ(getContext(), i));
    }

    public void setItemBackground(@Nullable Drawable drawable) {
        this.ॱॱ.ॱ(drawable);
    }

    public void setItemHorizontalPadding(@Dimension int i) {
        this.ॱॱ.ˋ(i);
    }

    public void setItemHorizontalPaddingResource(@DimenRes int i) {
        this.ॱॱ.ˋ(getResources().getDimensionPixelSize(i));
    }

    public void setItemIconPadding(@Dimension int i) {
        this.ॱॱ.ˊ(i);
    }

    public void setItemIconPaddingResource(int i) {
        this.ॱॱ.ˊ(getResources().getDimensionPixelSize(i));
    }

    public void setCheckedItem(@IdRes int i) {
        MenuItem findItem = this.ᐝ.findItem(i);
        if (findItem != null) {
            this.ॱॱ.ˊ((bj) findItem);
        }
    }

    public void setCheckedItem(@NonNull MenuItem menuItem) {
        MenuItem findItem = this.ᐝ.findItem(menuItem.getItemId());
        if (findItem != null) {
            this.ॱॱ.ˊ((bj) findItem);
            return;
        }
        throw new IllegalArgumentException("Called setCheckedItem(MenuItem) with an item that is not in the current menu.");
    }

    public void setItemTextAppearance(@StyleRes int i) {
        this.ॱॱ.ˎ(i);
    }

    private MenuInflater ˎ() {
        if (this.ʽ == null) {
            this.ʽ = new az(getContext());
        }
        return this.ʽ;
    }

    private ColorStateList ˊ(int i) {
        TypedValue typedValue = new TypedValue();
        if (!getContext().getTheme().resolveAttribute(i, typedValue, true)) {
            return null;
        }
        ColorStateList ˊ = ar.ˊ(getContext(), typedValue.resourceId);
        if (!getContext().getTheme().resolveAttribute(o.ah.c.ʽॱ, typedValue, true)) {
            return null;
        }
        int i2 = typedValue.data;
        int defaultColor = ˊ.getDefaultColor();
        return new ColorStateList(new int[][]{ˏ, ˊ, EMPTY_STATE_SET}, new int[]{ˊ.getColorForState(ˏ, defaultColor), i2, defaultColor});
    }
}
